package com.ete.lib.upload.ui

import android.content.Context
import android.view.LayoutInflater
import androidx.appcompat.app.AppCompatDialog
import com.ete.lib.upload.databinding.DialogInputDesQuestionBinding
import com.ete.lib.upload.logZip.UploadLogUtil

/**
 * Author:LiXian
 * <p>
 * Desc:TODO
 * Version:1.0
 * date 2023/12/20 14:23
 */
class InputDescriptionDialog(mContext: Context, var mCallback: (String) -> Unit)
    : AppCompatDialog(mContext, UploadLogUtil.mUploadEntry.mAppDialogStyle) {

    private val mBinding = DialogInputDesQuestionBinding.inflate(LayoutInflater.from(context))

    fun initDialog() {
        setContentView(mBinding.root)
        mBinding.dialogBtnCancel.setOnClickListener { dismiss() }
        mBinding.dialogIvClose.setOnClickListener {
            dismiss()
        }
        mBinding.dialogBtnOk.setOnClickListener {
            mCallback.invoke(mBinding.dialogEtInput.text.toString())
            dismiss()
        }
    }

    override fun onStart() {
        super.onStart()
        val width = UploadLogUtil.getDialogWidth(0.55F)
        if (window != null) {
            val mLayoutParams = window!!.attributes
            mLayoutParams.width = width
            mLayoutParams.height = mLayoutParams.height
            window!!.attributes = mLayoutParams
        }
    }

    override fun show() {
        super.show()
        UploadLogUtil.fullScreen(window)
    }
}